package 简单的工厂模式.工厂模式demo.计算器;

import java.util.Scanner;

/**
 * @author zyl
 * @Description
 * @since 2023/12/26 9:27
 */

public class Test {
    public static void main(String[] args) {
        try {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入数字A");
            Double numberA = Double.valueOf(sc.nextLine());
            System.out.println("请输入运算符(+,-,*,/):");
            String operator = sc.nextLine();
            System.out.println("请输入数字B");
            Double numberB = Double.valueOf(sc.nextLine());
            Double result = null;

            switch (operator){
                case "+":
                    result = numberA + numberB;
                    break;
                case "-":
                    result = numberA - numberB;
                    break;
                case "*":
                    result = numberA * numberB;
                    break;
                case "/":
                    result = numberA / numberB;
                    break;
            }
            System.out.println("结果是:" + result);
        }catch (Exception e){
            System.out.println("您输入的值有误" + e);
        }

    }
}
